using System;
using System.IO;
using Smart.Model;
using UnityEditor;
using UnityEngine;

namespace Smart.Editor
{
    [InitializeOnLoad]
    public static class Startup
    {
        private const string ScriptAssembliesDir = "Library/ScriptAssemblies";
        private const string CodeDir = "Assets/Res/Code/";
        private const string HotfixDll = "Hotfix.dll";
        private const string HotfixPdb = "Hotfix.pdb";

        static Startup()
        {
            if (!Application.isPlaying)
            {
                File.Copy(Path.Combine(ScriptAssembliesDir, HotfixDll), Path.Combine(CodeDir, "Hotfix.dll.bytes"), true);
                File.Copy(Path.Combine(ScriptAssembliesDir, HotfixPdb), Path.Combine(CodeDir, "Hotfix.pdb.bytes"), true);

                Model.Logger.Log($"复制Hotfix.dll, Hotfix.pdb到Res/Code完成");

                AssetDatabase.Refresh();
            }
        }
    }
}